home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: MotionBlur.ieb 1.12, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 2/2 1997 Stockholm/Sweden ** ** Create motion blur effect on image. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' Angle=0 ; Length=32 ; Step=2 ; MixVal=20 if command ~= '' then parse var command '#'Method '#'Direc Angle Length Step MixVal 'IE_TO_FRONT' form = 'FORM "Motion Blur" " OK | Cancel "', ' TEXT,"Motion Blur creates a `sweeping` blur effect in the desired direction."' if command = '' then form = form||' CYCLE,"Method:","Mix (blurring)|Max (brighten)|Min (darken)",0', form = form||' INTEGER,"Mix sharpness (Mix method only)",0,100,'MixVal',SLIDER', ' INTEGER,"Angle:",-1800,1800,'Angle',SLIDER', ' INTEGER,"Length:",1,256,'Length',SLIDER', ' INTEGER,"Step:",1,32,'Step',SLIDER' if command = '' then form = form||' CHECKBOX,"Blur both edges?",0' form if command = '' then do parse var result ok Method MixVal Angle Length Step Direc . if ok = 0 then return '<ERROR' select when Method = 0 then Method = "MIX" when Method = 1 then Method = "MAX" when Method = 2 then Method = "MIN" end end else do parse var result ok MixVal Angle Length Step . if ok = 0 then return '<ERROR' Method = 'none' Direc = 'none' end back = '#'Method '#'strip(Direc) Angle Length Step MixVal return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' parse var options '#'Method '#'Direc Angle Length Step MixVal if add_mathlib() = '<ERROR>' then return '<ERROR>' 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'PROJECT_INFO' LoadImage 'WIDTH' /* image width */ IW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' /* image height */ IH = RESULT do until ((Angle < 360)&(Angle >= 0)) if Angle > 359 then Angle = Angle - 360 if Angle < 0 then Angle = Angle + 360 end if Method = 'MIX' then Method = 'MIX' MixVal Angle = Angle * 3.14159265 /180 if Direc = 0 then do /* single */ 'SCALE' LoadImage IW IH 'FAST' BackImage = Result do i = 1 to Length by Step 'MARK' LoadImage 'PRIMARY' 'MARK' BackImage 'SECONDARY' 'COMPOSITE' (Length-i)*cos(Angle) (i-Length)*sin(Angle) Method TempImage = Result 'CLOSE' BackImage BackImage = TempImage end 'CLOSE' LoadImage OutputImage = BackImage end else do /* both */ do i = 1 to Length by Step 'MARK' LoadImage 'PRIMARY' 'MARK' LoadImage 'SECONDARY' 'COMPOSITE' (Length-i)*cos(Angle) (i-Length)*sin(Angle) Method TempImage = Result 'CLOSE' LoadImage LoadImage = TempImage end OutputImage = LoadImage end if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ add_mathlib: if ~show(L,'rexxmathlib.library') then do if exists('LIBS:rexxmathlib.library') then do if ~addlib('rexxmathlib.library',0,-30,0) then do 'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "' return '<ERROR>' end end /* lib found on disk */ else do 'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "' return '<ERROR>' end end /* lib exists in mem */ return 'OK' /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'